package S06;
public class Person { //没有明确指定父类，其父类就是Object
	private String id; //身份证号
	private String name; //姓名
	private String tel; //电话
	public Person(String id, String name, String tel) {
		this.id = id;
		this.name = name;
		this.tel = tel;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getSex() {
		return Integer.parseInt(id.substring(16, 17)) % 2 == 1 ? "男" : "女";
	}
	public String getBirthday() { //410105200409250115 "2004-09-25"
		return id.substring(6, 10) + "-" + id.substring(10, 12) + "-" + id.substring(12, 14);
	}
	@Override  //这是注解，表示这是重写父类的方法
	public String toString() { //重写父类Object的toString方法
		return name + "，" + getSex() + "，出生于" + getBirthday() + "，联系电话" + tel;
	}
}
